#include <iostream>
#include <algorithm>
using namespace std;

int n;
int a[1005],cnt = 0;
int tree[1005];

void MiddleCreateTree(int root){
    if(root>n)    return;
    MiddleCreateTree(root*2);
    tree[root] = a[cnt++];
    MiddleCreateTree(root*2+1);
}

signed main()
{
    cin>>n;
    for(int i=0;i<n;i++)    cin>>a[i];
    sort(a,a+n);
    MiddleCreateTree(1);
    cout<<tree[1];
    for(int i=2;i<=n;i++)    cout<<" "<<tree[i];
    return 0;
}
